#include <cstdio>
#include <vector>
#include <queue>
using namespace std;
struct node{
    int level;
    vector<int> next;
};
vector<node> v;
int tot[100] = {0};
int N, M, maxlevel = 0;
void bfs()
{
    queue<int> q;//Only used in this function, so define it inside the function. 
    q.push(1);
    while(!q.empty())
    {
        int front = q.front(), next, level;
        int size = v[front].next.size();
        for(int i = 0; i < size; ++i)
        {
            next = v[front].next[i];
            level = v[front].level + 1;
            v[next].level = level;
            q.push(next);
            if(level > maxlevel)maxlevel = level;
        }
        q.pop();
        if(0 == size)
            tot[v[front].level]++;
    }   
}
main()
{
    scanf("%d%d", &N, &M);
    v.resize(N + 1);
    int ancestor, cnt, offspring;
    for(int i = 0; i < M; i++)
    {
        scanf("%d%d", &ancestor, &cnt);
        for(int j = 0; j < cnt; ++j)
        {
            scanf("%d", &offspring);
            v[ancestor].next.push_back(offspring);
        }
    }
    v[1].level = 1;
    bfs();
    printf("%d", tot[1]);
    for(int i = 2; i <= maxlevel; ++i)
    {
        printf(" %d", tot[i]);
    }
    putchar('\n');
    return 0;
}